template <class T>
class Stack
{
public:
	Stack(int capacity = 0) :_capacity(0), _top(0), _arr(nullptr)
	{
		if (_capacity > 0)
		{
			_capacity = capacity;
			_top = 0;
			_arr = new T[capacity];
		}
	}

	~Stack() { delete[]_arr; }

	void Push(const T& x);

	bool IsEmpty() {
		return _top == 0;
	}

	const T& Top()
	{
		assert(!IsEmpty());
		return _arr[_top - 1];
	}

	void Pop()
	{
		assert(!IsEmpty());
		_top--;
	}
private:
	T* _arr;
	size_t _top;
	size_t _capacity;
};


